.\" Copyright (c) 2002-2007 Hypertriton, Inc. <http://hypertriton.com/>
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
.\" INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
.\" (INCLUDING BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
.\" SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
.\" STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd August 23, 2002
.Dt AG_VERSION 3
.Os
.ds vT Agar API Reference
.ds oS Agar 1.3
.Sh NAME
.Nm AG_Version
.Nd agar data file versioning
.Sh SYNOPSIS
.Bd -literal
#include <agar/core.h>
.Ed
.Sh DESCRIPTION
The agar
.Nm
interface encodes or decodes versioning information.
This includes a magic string and two 32-bit version numbers:
.Bd -literal
typedef struct ag_version {
	Uint32 major, minor;
} AG_Version;
.Ed
.Pp
The
.Fa major
is incremented whenever a change introduces binary incompatibility with
previous versions of the data files.
.Pp
The
.Dv minor
member is incremented whenever a change is made in the data file, but binary
compatibility is preserved.
.Pp
Major changes that would otherwise break binary compatibility can be dealt
with by increasing only the minor version number and adding compatibility code
in the loader routine.
.Sh VERSIONING
.nr nS 1
.Ft "int"
.Fn AG_ReadVersion "AG_DataSource *ds" "const char *magic" "const AG_Version *ver" "AG_Version *rver"
.Pp
.Ft "void"
.Fn AG_WriteVersion "AG_DataSource *ds" "const char *magic" "const AG_Version *ver"
.Pp
.Ft "int"
.Fn AG_ReadObjectVersion "AG_DataSource *ds" "AG_Object *obj"
.Pp
.Ft "void"
.Fn AG_WriteObjectVersion "AG_DataSource *ds" "const AG_Object *obj"
.Pp
.nr nS 0
The
.Fn AG_ReadVersion
function reads version information from
.Fa fd
and returns 0 if the following data is binary compatible against the version
represented by
.Fa ver ,
or -1 if the data is not compatible.
If
.Fa rver
is not NULL, it is initialized with the version information read from
.Fa fd .
.Pp
The
.Fn AG_WriteVersion
function writes version information from the structure
.Fa ver
to
.Fa ds .
.Pp
The
.Fn AG_ReadObjectVersion
and
.Fn AG_WriteObjectVersion
variants use the version information contained in the
.Ft AG_ObjectClass
structure of
.Xr AG_Object 3 ,
using the name of the object class as a signature.
.Sh SEE ALSO
.Xr AG_DataSource 3 ,
.Xr AG_Intro 3
.Sh HISTORY
The
.Nm
interface first appeared in Agar 1.0
